/*
 * Copyright @ 苏州瑞云信息技术有限公司 All rights reserved.
 */
package cn.com.recloud.bbs.controller;


import cn.com.recloud.bbs.dto.CampaignAnalysisDTO;
import cn.com.recloud.core.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.com.recloud.one.spring.controller.BaseController;

import cn.com.recloud.bbs.entity.bbs_shared_log;
import cn.com.recloud.bbs.service.SharedLogService;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author kim dong
 * @date 2020-06-08
 */
@RestController
@RequestMapping("/api/bbs/sharedlog")
@Api(tags = "分享记录")
public class SharedLogController extends BaseController<bbs_shared_log,SharedLogService> {
    @Autowired
    private SharedLogService sharedLogService;

    @PostMapping("/serchshared")
    @ApiOperation("查询分享明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dto", value = "活动查询的dto")
    })
    public Result serchShared(@RequestBody CampaignAnalysisDTO dto){
        Map map=sharedLogService.serchShared(dto);
        return new Result(map);
    }
    @PostMapping("exportshared")
    @ApiOperation("导出分享明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "response", value = "响应对象"),
            @ApiImplicitParam(name = "campaign", value = "活动查询的dto")
    })
    public void exportShared(HttpServletResponse response, @RequestBody CampaignAnalysisDTO campaign) {
        sharedLogService.exportShared(campaign, response);
    }


    @PostMapping("savesharelog/{type}")
    @ApiOperation("记录分享信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "分享类型"),
            @ApiImplicitParam(name = "bbsSharedLog", value = "分享实体")
    })
    public Result saveShareLog(@PathVariable("type")String type,@RequestBody bbs_shared_log bbsSharedLog ){
        sharedLogService.saveShareLog(bbsSharedLog,type);
        return Result.SUCCESS;
    }
}

